﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using TL_Cloud.Core.Entities;

namespace TL_Cloud.Models.BookShop
{
    public partial class Bk_Pics : BaseEntity
    {
        public string PicId { get; set; }
        public string BookId { get; set; }
        public string PicUrl { get; set; }
        public string PicName { get; set; }
        public int? Sort { get; set; }
        public string Remark { get; set; } 
        public string CreateUserId { get; set; }
        public string CreateUserName { get; set; }
        public DateTime? ModifyDate { get; set; }
        public string ModifyUserId { get; set; }
        public string ModifyUserName { get; set; }

        
        public override void Create(string userId, string userName)
        {
            this.PicId = Guid.NewGuid().ToString();
            this.CreateDate = DateTime.Now;
            this.CreateUserId = userId;
            this.CreateUserName = userName;
        }
        public override void Modify(string userId, string userName)
        {
            this.ModifyDate = DateTime.Now;
            this.ModifyUserId = userId;
            this.ModifyUserName = userName;
        }
        public override void Mapping(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Bk_Pics>(entity =>
            {
                entity.HasKey(e => e.PicId);

                entity.ToTable("BK_Pics");

                entity.Property(e => e.PicId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .ValueGeneratedNever();

                entity.Property(e => e.BookId)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.CreateDate).HasColumnType("datetime");

                entity.Property(e => e.CreateUserId)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.CreateUserName)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.ModifyDate).HasColumnType("datetime");

                entity.Property(e => e.ModifyUserId)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.ModifyUserName)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.PicName)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.PicUrl)
                    .HasMaxLength(500)
                    .IsUnicode(false);

                entity.Property(e => e.Remark).HasColumnType("text");
            });
        }
    }
}
